home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / answers / rec / puzzles / archive / arithmetic / part2 < prev    next >
Text File  |  1993-08-17  |  22KB  |  578 lines

  1. Newsgroups: rec.puzzles,news.answers,rec.answers
  2. Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!spool.mu.edu!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!questrel!chris
  3. From: chris@questrel.com (Chris Cole)
  4. Subject: rec.puzzles Archive (arithmetic), part 04 of 35
  5. Message-ID: <puzzles/archive/arithmetic/part2_745653851@questrel.com>
  6. Followup-To: rec.puzzles
  7. Summary: This is part of an archive of questions
  8.  and answers that may be of interest to
  9.  puzzle enthusiasts.
  10.  Part 1 contains the index to the archive.
  11.  Read the rec.puzzles FAQ for more information.
  12. Sender: chris@questrel.com (Chris Cole)
  13. Reply-To: archive-comment@questrel.com
  14. Organization: Questrel, Inc.
  15. References: <puzzles/archive/Instructions_745653851@questrel.com>
  16. Date: Wed, 18 Aug 1993 06:04:29 GMT
  17. Approved: news-answers-request@MIT.Edu
  18. Expires: Thu, 1 Sep 1994 06:04:11 GMT
  19. Lines: 556
  20. Xref: senator-bedfellow.mit.edu rec.puzzles:24990 news.answers:11510 rec.answers:1910
  21.  
  22. Archive-name: puzzles/archive/arithmetic/part2
  23. Last-modified: 17 Aug 1993
  24. Version: 4
  25.  
  26.  
  27. ==> arithmetic/digits/squares/three.digits.p <==
  28. What squares consist entirely of three digits (e.g., 1, 4, and 9)?
  29.  
  30. ==> arithmetic/digits/squares/three.digits.s <==
  31. The full set of solutions up to 10**12 is
  32.               1 ->                            1
  33.               2 ->                            4
  34.               3 ->                            9
  35.               7 ->                           49
  36.              12 ->                          144
  37.              21 ->                          441
  38.              38 ->                         1444
  39.             107 ->                        11449
  40.             212 ->                        44944
  41.           31488 ->                   9914 94144
  42.           70107 ->                  49149 91449
  43.         3 87288 ->               14 99919 94944
  44.       956 10729 ->          9 14141 14499 11441
  45.      4466 53271 ->        199 49914 44949 99441
  46.     31487 17107 ->       9914 41941 99144 49449
  47.   2 10810 79479 ->    4 44411 91199 99149 11441
  48.  
  49. If the algorithm is used in the form I presented it before, generating
  50. the whole set P_n before starting on P_{n+1}, the store requirements
  51. begin to become embarassing. For n>8 I switched to a depth-first
  52. strategy, generating all the elements in P_i (i=9..12) congruent to
  53. a particular x in P_8 for each x in turn. This means the solutions
  54. don't come out in any particular order, of course. CPU time was 16.2
  55. seconds (IBM 3084).
  56.  
  57. In article <1990Feb6.025205.28153@sun.soe.clarkson.edu>, Steven
  58. Stadnicki suggests alternate triples of digits, in particular {1,4,6}
  59. (with many solutions) and {2,4,8} (with few). I ran my program on
  60. these as well, up to 10**12 again:
  61.               1 ->                            1
  62.               2 ->                            4
  63.               4 ->                           16
  64.               8 ->                           64
  65.              12 ->                          144
  66.              21 ->                          441
  67.              38 ->                         1444
  68.             108 ->                        11664
  69.             119 ->                        14161
  70.             121 ->                        14641
  71.             129 ->                        16641
  72.             204 ->                        41616
  73.             408 ->                      1 66464
  74.             804 ->                      6 46416
  75.            2538 ->                     64 41444
  76.            3408 ->                    116 14464
  77.            6642 ->                    441 16164
  78.           12908 ->                   1666 16464
  79.           25771 ->                   6641 44441
  80.           78196 ->                  61146 14416
  81.           81619 ->                  66616 61161
  82.         3 33858 ->               11 14611 64164
  83.      2040 00408 ->         41 61616 64641 66464
  84.      6681 64962 ->        446 44441 64444 61444
  85.      8131 18358 ->        661 16146 41166 16164
  86.     40182 85038 ->      16146 61464 66146 61444  (Steven's last soln.)
  87.   1 20068 50738 ->    1 44164 46464 46111 44644
  88.   1 26941 38988 ->    1 61141 16464 66616 64144
  89.   1 27069 43631 ->    1 61466 41644 14114 64161
  90.   4 01822 24262 ->   16 14611 14664 16614 44644
  91.   4 05784 63021 ->   16 46611 66114 66644 46441
  92.  78 51539 12392 -> 6164 66666 14446 44111 61664
  93. and
  94.               2 ->                            4
  95.              22 ->                          484
  96.             168 ->                        28224
  97.             478 ->                      2 28484
  98.            2878 ->                     82 82884 (Steven's last soln.)
  99.      2109 12978 ->         44 48428 42888 28484
  100. (so the answer to Steven's "Are there any more at all?" is "Yes".)
  101.  
  102. The CPU times were 42.9 seconds for {1,4,6}, 18.7 for {2,4,8}. This
  103. corresponds to an interesting point: the abundance of solutions for
  104. {1,4,6} is associated with abnormally large sets P_n (|P_8| = 16088
  105. for {1,4,6} compared to |P_8| = 5904 for {1,4,9}) but the deficiency
  106. of solutions for {2,4,8} is *not* associated with small P_n's (|P_8|
  107. = 6816 for {2,4,8}). Can anyone wave a hand convincingly to explain
  108. why the solutions for {2,4,8} are so sparse?
  109.  
  110. I suspect we are now getting to the point where an improved algorithm
  111. is called for. The time to determine all the n-digit solutions (i.e.
  112. 2n-digit squares) using this last-significant-digit-first is essentially
  113. constant * 3**n. Dean Hickerson in <90036.134503HUL@PSUVM.BITNET>, and
  114. Ilan Vardi in <1990Feb5.214249.22811@Neon.Stanford.EDU>, suggest using
  115. a most-significant-digit-first strategy, based on the fact that the
  116. first n digits of the square determine the (integral) square root; this
  117. also has a running time constant * 3**n. Can one attack both ends at
  118. once and do better?
  119.  
  120. Chris Thompson
  121. JANET:    cet1@uk.ac.cam.phx
  122. Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk
  123.  
  124. Hey guys, what about
  125.  
  126. 648070211589107021 ^ 2 = 419994999149149944149149944191494441
  127.  
  128. This was found by David Applegate and myself (about 5 minutes on a DEC 3100,
  129. program in C).
  130.  
  131. This is the largest square less than 10^42 with the 149-property; checking
  132. took a bit more than an hour of CPU time.
  133.  
  134. As somebody suggested, we used a combined most-significant/least-significant
  135. digits attack.  First we make a table of p-digit prefixes (most significant
  136. p digits) that could begin a root whose square has the 149 property in its
  137. first p digits.  We organize this table into buckets by the least
  138. significant q digits of the prefixes.  Then we enumerate the s digit
  139. suffixes whose squares have the 149 property in their last s digits.  For
  140. each such suffix, we look in the table for those prefixes whose last q
  141. digits match the first q of the suffix.  For each match, we consider the p +
  142. s - q digit number formed by overlapping the prefix and the suffix by q
  143. digits.  The squares of these overlap numbers must contain all the squares
  144. with the 149 property.
  145.  
  146. The time expended is O(3^p) to generate the prefix table, O(3^s) to
  147. enumerate the suffixes, and O(3^(p+s) / 10^q) to check the overlaps (being
  148. very rough and ignoring the polynomial factors) By judiciously chosing p, q,
  149. and s, we can fix things so that each bucket of the table has around O(1)
  150. entries: set q = p log10(3).  Setting p = s, we end up looking for squares
  151. whose roots have n = 2 - log10(3) digits, with an algorithm that takes time
  152. O( 3 ^ [n / (2 - log10(3)]) ), roughly time O(3^[.66n]).  Compared to the
  153. O(3^n) performance of either single-ended algorithm, this lets us check 50%
  154. more digits in the same amount of time (ignoring polynomial factors).  Of
  155. course, the space cost of the combined-ends method is high.
  156.  
  157. -- Guy and Dave
  158. -- 
  159. Guy Jacobson              School of Computer Science
  160. Carnegie Mellon     arpanet : guy@cs.cmu.edu
  161. Pittsburgh, PA  15213    csnet   : Guy.Jacobson%a.cs.cmu.edu@csnet-relay
  162. (412) 268-3056        uucp    : ...!{seismo, ucbvax, harvard}!cs.cmu.edu!guy
  163.  
  164. Here is an algorithm which takes O(sqrt(n)log(n)) steps to find all perfect
  165. squares < n whose only digits are 1, 4 and 9.
  166.  
  167. This doesn't sound too great *but* it doesn't use a lot of memory and only
  168. requires addition and <.  Also, the actual run time will depend on where the
  169. first non-{1,4,9} digit appears in each square.
  170.  
  171.     set n = 1
  172.     set odd = 1
  173.  
  174.     while(n < MAXVAL)
  175.     {
  176.         if(all digits of n are in {1,4,9})
  177.         {
  178.             print n
  179.         }
  180.  
  181.         add 2 to odd
  182.         add odd to n
  183.     }
  184.  
  185. This works because (X+1)^2 - x^2 = 2x+1.
  186. That is, if you start with 0 and add successive odd
  187. numbers to it you get 0+1=1, 1+3=4, 4+5=9, 9+7=16 etc.
  188. I've started the algorithm at 1 for convenience.
  189.  
  190. The "O" value comes from looking at at most all digits
  191. (log(n)) of all perfect squares < n (sqrt(n) of them)
  192. at most a constant number of times. 
  193.  
  194. I didn't save the articles with algorithms claiming to be
  195. O(3^log(n)) so I don't know if their calculations needed
  196. to (or did) account for multiplication or sqrt() of large
  197. numbers.  O(3^log(n)) sounds reasonable so I'm going to
  198. assume they did unless I hear otherwise.
  199.  
  200. Any comments? Please email if you just want to refresh my memory
  201. on the other algorithms.
  202.  
  203. Andrew Charles
  204. acgd@ihuxy.ATT.COMM
  205.  
  206. ==> arithmetic/digits/squares/twin.p <==
  207. Let a twin be a number formed by writing the same number twice,
  208. for instance, 81708170 or 132132.  What is the smallest square twin?
  209.  
  210. ==> arithmetic/digits/squares/twin.s <==
  211. 1322314049613223140496 = 36363636364 ^ 2.
  212.  
  213. The key to solving this puzzle is looking at the basic form of these
  214. "twin" numbers, which is some number k = 1 + 10^n multiplied by some number
  215. 10^(n-1) <= a < 10^n.  If ak is a perfect square, k must have some
  216. repeated factor, since a<k. Searching the possible values of k for one
  217. with a repeated factor eventually turns up the number 1 + 10^11 = 11^2
  218. * 826446281.  So, we set a=826446281 and ak = 9090909091^2 =
  219. 82644628100826446281, but this needs leading zeros to fit the pattern.
  220. So, we multiply by a suitable small square (in this case 16) to get the
  221. above answer.
  222.  
  223. ==> arithmetic/digits/sum.of.digits.p <==
  224. Find sod ( sod ( sod (4444 ^ 4444 ) ) ).
  225.  
  226. ==> arithmetic/digits/sum.of.digits.s <==
  227. let X = 4444^4444
  228.  
  229. sod(X) <= 9 * (# of digits) < 145900
  230. sod(sod(X)) <= sod(99999) = 45
  231. sod(sod(sod(X))) <= sod(39) = 12
  232.  
  233. but sod(sod(sod(X))) = 7 (mod 9)
  234.  
  235. thus sod(sod(sod(X))) = 7
  236.  
  237. ==> arithmetic/digits/zeros/million.p <==
  238. How many zeros occur in the numbers from 1 to 1,000,000?
  239.  
  240. ==> arithmetic/digits/zeros/million.s <==
  241. In the numbers from 10^(n-1) through 10^n - 1, there are 9 * 10^(n-1)
  242. numbers of n digits each, so 9(n-1)10^(n-1) non-leading digits, of
  243. which one tenth, or 9(n-1)10^(n-2), are zeroes.  When we change the
  244. range to 10^(n-1) + 1 through 10^n, we remove 10^(n-1) and put in
  245. 10^n, gaining one zero, so
  246.  
  247.     p(n) = p(n-1) + 9(n-1)10^(n-2) + 1 with p(1)=1.
  248.  
  249. Solving the recurrence yields the closed form
  250.  
  251.     p(n) = n(10^(n-1)+1) - (10^n-1)/9.
  252.  
  253. For n=6, there are 488,895 zeroes, 600,001 ones, and 600,000 of all other
  254. digits.
  255.  
  256. ==> arithmetic/digits/zeros/trailing.p <==
  257. How many trailing zeros are in the decimal expansion of n!?
  258.  
  259. ==> arithmetic/digits/zeros/trailing.s <==
  260. The general answer to the question
  261. "what power of p divides x!" where p is prime
  262. is (x-d)/(p-1) where d is the sum of the digits of (x written in base p).
  263.  
  264. So where p=5, 10 is written as 20 and is divisible by 5^2 (2 = (10-2)/4);
  265. x to base 10:     100    1000    10000    100000     1000000
  266. x to base 5:      400   13000   310000  11200000   224000000
  267. d          :        4       4        4         4           8
  268. trailing 0s in x!  24     249     2499     24999      249998
  269.  
  270. ==> arithmetic/magic.squares.p <==
  271. Are there large squares, containing only consecutive integers, all of whose
  272. rows, columns and diagonals have the same sum?  How about cubes?
  273.  
  274. ==> arithmetic/magic.squares.s <==
  275. These are called magic squares.  A magic square of order n (integers
  276. from 1 to n*n) has only one possible sum: (n*n+1)*n/2.
  277.  
  278. Odd and even order squares must be constructed by different approaches.
  279. For odd orders, the most common algorithm is a recursive scheme
  280. devised by de la Loubere about 300 years ago.  For even orders, one
  281. procedure is the Devedec algorithm, which treats even orders not
  282. divisible by 4 slightly differently from those which are divisible by
  283. 4 (doubly even).
  284.  
  285. For squares with odd-length sides, the following algorithm builds a magic
  286. square:
  287.  
  288. Put 1 in the middle box in the upper row. From then on, if it's
  289. possible to put the next number one box diagonally up and to the right
  290. (wrapping around if the edge of the grid is reached), do so, otherwise,
  291. put it directly below the last one.
  292.  
  293.                17 24  1  8 15
  294.                23  5  7 14 16 
  295.                 4  6 13 20 22
  296.                10 12 19 21  3 
  297.                11 18 25  2  9 
  298.  
  299. ...or even
  300.  
  301.          47 58 69 80  1 12 23 34 45
  302.          57 68 79  9 11 22 33 44 46
  303.          67 78  8 10 21 32 43 54 56
  304.          77  7 18 20 31 42 53 55 66
  305.           6 17 19 30 41 52 63 65 76
  306.          16 27 29 40 51 62 64 75  5
  307.          26 28 39 50 61 72 74  4 15
  308.          36 38 49 60 71 73  3 14 25
  309.          37 48 59 70 81  2 13 24 35
  310.  
  311. See archive entry knight.tour for magic squares that are knight's tours.
  312.  
  313. To get a 4x4 square, write the numbers in order across each row, filling
  314. the square...
  315.  
  316. 1  2  3  4
  317. 5  6  7  8
  318. 9  10 11 12
  319. 13 14 15 16
  320.  
  321. then use the following pattern as a mask:
  322.  
  323. .  X  X  .
  324. X  .  .  X
  325. X  .  .  X
  326. .  X  X  .
  327.  
  328. Everywhere there is an X, complement the number (subtract it from
  329. n*n+1).  For the 4x4 you get:
  330.  
  331. 1  15 14 4
  332. 12 6  7  9
  333. 8  10 11 5
  334. 13 3  2  16
  335.  
  336. For n even (n>4):
  337.  
  338. Make an initial magic square by writing an n/2 magic square four times
  339. (the same one each time).  Now, although this square adds up right we
  340. have the numbers 1 to n*n/4 written four times each.  To fix this,
  341. simply add to it n*n/4 times one of the following magic squares:
  342.  
  343. if n/2 is odd (example: n/2=7),
  344.  
  345. 3 3 3 0 0 0 0 2 2 2 2 2 1 1   (there are int(n/4) 3s, int(n/4-1) 1s on each
  346. 3 3 3 0 0 0 0 2 2 2 2 2 1 1    row)
  347. 3 3 3 0 0 0 0 2 2 2 2 2 1 1
  348. 0 3 3 3 0 0 0 2 2 2 2 2 1 1   (this is row int(n/4)+1.  It starts with just
  349. 3 3 3 0 0 0 0 2 2 2 2 2 1 1    the one 0)
  350. 3 3 3 0 0 0 0 2 2 2 2 2 1 1
  351. 3 3 3 0 0 0 0 2 2 2 2 2 1 1
  352. 0 0 0 3 3 3 3 1 1 1 1 1 2 2   (the lower half is the same as the upper half
  353. 0 0 0 3 3 3 3 1 1 1 1 1 2 2    with 3<->0 and 1<->2 swapped.  This guarantees
  354. 0 0 0 3 3 3 3 1 1 1 1 1 2 2    that each number 1-n*n will appear in the
  355. 3 0 0 0 3 3 3 1 1 1 1 1 2 2    completed square)
  356. 0 0 0 3 3 3 3 1 1 1 1 1 2 2
  357. 0 0 0 3 3 3 3 1 1 1 1 1 2 2
  358. 0 0 0 3 3 3 3 1 1 1 1 1 2 2
  359.  
  360. if n/2 is even (example: n/2=4),
  361.  
  362. 0 0 3 3 2 2 1 1  (there are n/4 of each number on each row)
  363. 0 0 3 3 2 2 1 1
  364. 0 0 3 3 2 2 1 1
  365. 0 0 3 3 2 2 1 1
  366. 3 3 0 0 1 1 2 2
  367. 3 3 0 0 1 1 2 2
  368. 3 3 0 0 1 1 2 2
  369. 3 3 0 0 1 1 2 2
  370.  
  371. References:
  372.     "Magic Squares and Cubes"
  373.     W.S. Andrews
  374.     The Open Court Publishing Co.
  375.     Chicago, 1908
  376.  
  377.     "Mathematical Recreations"
  378.     M. Kraitchik
  379.     Dover
  380.     New York, 1953
  381.  
  382. ==> arithmetic/pell.p <==
  383. Find integer solutions to x^2 - 92y^2 = 1.
  384.  
  385. ==> arithmetic/pell.s <==
  386. x=1        y=0
  387. x=1151     y=120
  388. x=2649601  y=276240
  389. etc.
  390.  
  391. Each successive solution is about 2300 times the previous
  392. solution;  they are every 8th partial fraction (x=numerator,
  393. y=denominator) of the continued fraction for sqrt(92) = 
  394. [9,  1,1,2,4,2,1,1,18,  1,1,2,4,2,1,1,18,  1,1,2,4,2,1,1,18, ...]
  395.  
  396. Once you have the smallest positive solution (x1,y1) you
  397. don't need to "search" for the rest.  You can obtain the nth positive
  398. solution (xn,yn) by the formula
  399.  
  400. (x1 + y1 sqrt(92))^n = xn + yn sqrt(92).
  401.  
  402. See Niven & Zuckerman's An Introduction to the Theory of Numbers.
  403. Look in the index under Pell's equation.
  404.  
  405. ==> arithmetic/subset.p <==
  406. Prove that all sets of n integers contain a subset whose sum is divisible by n.
  407.  
  408. ==> arithmetic/subset.s <==
  409. Consider the set of remainders of the partial sums a(1) + ... + a(i).
  410. Since there are n such sums, either one has remainder zero (and we're
  411. thru) or 2 coincide, say the i'th and j'th.  In this case, a(i+1) +
  412. ... + a(j) is divisible by n.  (note this is a stronger result since
  413. the subsequence constructed is of *adjacent* terms.)  Consider a(1)
  414. (mod n), a(1)+a(2) (mod n), ..., a(1)+...+a(n) (mod n).  Either at
  415. some point we have a(1)+...+a(m) = 0 (mod n) or else by the pigeonhole
  416. principle some value (mod n) will have been duplicated.  We win either
  417. way.
  418.  
  419. ==> arithmetic/sum.of.cubes.p <==
  420. Find two fractions whose cubes total 6.
  421.  
  422. ==> arithmetic/sum.of.cubes.s <==
  423. Restated:  
  424. Find X, Y, minimum Z (all positive integers) where
  425. (X/Z)^3 + (Y/Z)^3 = 6
  426.  
  427. Again, a generalized solution would be nice.
  428.  
  429. You are asking for the smallest z s.t. x^3 + y^3 = 6*z^3 and x,y,z in Z+.
  430. In general, questions like these are extremely difficult; if you're
  431. interested take a look at books covering Diophantine equations
  432. (especially Baker's work on effective methods of computing solutions).
  433.  
  434. Dudeney mentions this problem in connection with #20 in _The Canterbury
  435. Puzzles_; the smallest answer is (17/21)^3 + (37/21)^3 = 6.
  436.  
  437. For the interest of the readers of this group I'll quote:
  438.  
  439.    "Given a known case for the expression of a number as the sum or
  440. difference of two cubes, we can, by formula, derive from it an infinite
  441. number of other cases alternately positive and negative.  Thus Fermat,
  442. starting from the known case 1^3 + 2^3 = 9 (which we will call a
  443. fundamental case), first obtained a negative solution in bigger
  444. figures, and from this his positive solution in bigger figures still.
  445. But there is an infinite number of fundamentals, and I found by trial
  446. a negative fundamental solution in smaller figures than his derived
  447. negative solution, from which I obtained the result shown above.  That
  448. is the simple explanation."
  449.  
  450. In the above paragraph Dudeney is explaining how he derived (*by hand*)
  451. that (415280564497/348671682660)^3 + (676702467503/348671682660)^3 = 9.
  452.  
  453. He continues:
  454.  
  455. "We can say of any number up to 100 whether it is possible or not to
  456. express it as the sum of two cubes, except 66.  Students should read
  457. the Introduction to Lucas's _Theorie des Nombres_, p. xxx."
  458.  
  459. "Some years ago I published a solution for the case 6 = (17/21)^3 +
  460. (37/21)^3, of which Legendre gave at some length a 'proof' of
  461. impossibility; but I have since found that Lucas anticipated me in
  462. a communication to Sylvester."
  463.  
  464. ==> arithmetic/sums.of.powers.p <==
  465. Partition 1,2,3,...,16 into two equal sets, such that the sums of the
  466. numbers in each set are equal, as are the sums of their squares and cubes.
  467.  
  468. ==> arithmetic/sums.of.powers.s <==
  469. The solution is A = {1,4,6,7,10,11,13,16}
  470.                 B = {2,3,5,8,9,12,14,15}                                                         
  471.  
  472. Let X+k be a set formed by adding k to all elements of X.
  473. Then A+k and B+k have the property of satisfying i,ii and iii.
  474. That means, any 16 numbers in A.P can be partioned in such a way to
  475. satisfy i,ii and iii.
  476.  
  477. How do we arrive at the above solution without using a computer?
  478.  
  479. By the preceding discussion,
  480.  
  481.     A1 = A-1 = {0,3,5,6,9,10,12,15}
  482.         B1 = B-1 = {1,2,4,7,8,11,13,14}
  483.  
  484. have the property of satisfying i,ii and iii.
  485. Notice that all numbers of A1 have even number of 1's in binary and
  486. all numbers of B1 have odd number of 1's in binary. Essentially the
  487. above partition is a partition based on parity.
  488.  
  489. Observation:
  490.  
  491.     Partition of (n+1) bit numbers based on parity into two
  492. groups A and B (each consisting of 2^n elements) satisfies
  493.  
  494.  sum of kth powers of elements of A = sum of kth powers of elements of B
  495.  
  496. for k=1,2,...,n. (The above puzzle is a special case n=3).
  497.  
  498.  
  499. The above observation also holds for any radix. In radix r we will have
  500. r groups.
  501.  
  502. Infact,
  503.  
  504.     Any r^(n+1) terms in A.P can be partitioned into r groups (each of
  505. r^n elements) such that sum of kth powers of all r groups is same (k=1,2,...,n)
  506.  
  507. Finding such groups with minimal number of elements (less than r^n) appears to
  508. be more difficult!
  509.  
  510. ALL THIS APPEARS TO BE INTERESTING. IS IT A CONSEQUENCE OF A SIMPLE THEOREM OF
  511. NUMBER THEORY? HOW DO I PROVE THIS?
  512.  
  513. Thanks in advance for any clues,
  514.  
  515. -- ramana@svl.cdc.com (Mr. Ramana (Indian analyst))
  516.  
  517. ==> arithmetic/tests.for.divisibility/eleven.p <==
  518. What is the test to see if a number is divisible by eleven?
  519.  
  520.  
  521. ==> arithmetic/tests.for.divisibility/eleven.s <==
  522. If the alternating sum of the digits is divisible by eleven, so is the number.
  523.  
  524. For example, 1639 leads to 9 - 3 + 6 - 1 = 11, so 1639 is divisible by 11.
  525.  
  526. Proof:
  527. Every integer n can be expressed as 
  528. n = a1*(10^k) + a2*(10^k-1)+ .....+ a_k+1
  529. where a1, a2, a3, ...a_k+1 are integers between 0 and 9.
  530. 10 is congruent to -1 mod(11).
  531. Thus if (-1^k)*a1 + (-1^k-1)*a2 + ...+ (a_k+1) is congruent to 0mod(11) then 
  532. n is divisible by 11.
  533.  
  534. ==> arithmetic/tests.for.divisibility/nine.p <==
  535. What is the test to see if a number is divisible by nine?
  536.  
  537. ==> arithmetic/tests.for.divisibility/nine.s <==
  538. If the sum of the digits is divisible by nine, so is the number.
  539.  
  540. Proof:
  541. Every integer n can be expressed as 
  542. n = a1*(10^k) + a2*(10^k-1)+ .....+ a_k+1
  543. where a1, a2, a3, ...a_k+1 are integers between 0 and 9.
  544. Note that 10 is congruent to 1 (mod 9). Thus 10^k is congruent to 1 (mod 9) for
  545. every k >= 0.
  546. Thus n is congruent to (a1+a2+a3+....+a_k+1) mod(9).
  547. Hence (a1+a2+...+a_k+1) is divisible by 9 iff n is divisible by 9.
  548.  
  549. ==> arithmetic/tests.for.divisibility/seven.p <==
  550. What is the test to see if a number is divisible by seven?
  551.  
  552. ==> arithmetic/tests.for.divisibility/seven.s <==
  553. Take the last digit (n mod 10) and double it.
  554. Take the rest of the digits (n div 10) and subtract the doubled last
  555.     digit from it.
  556. The resulting number is divisible by 7 iff the original number
  557.     is divisible by 7.
  558.  
  559. Example:  Take 53445
  560.           Subtract (53445 mod 10) * 2 from (53445 div 10)
  561.                            -  5  * 2   +   5344
  562.                             = 5334
  563.       533 - 2 * 4 = 525
  564.       52 - 5 * 2 = 42 which is divisible by 7
  565.           so 53445 is divisible by 7.
  566.  
  567. ==> arithmetic/tests.for.divisibility/three.p <==
  568. What is the test to see if a number is divisible by three?
  569.  
  570. ==> arithmetic/tests.for.divisibility/three.s <==
  571. A number is divisible by three iff the sum of its digits is divisible by three.
  572. First, prove 10^N = 1 mod 3 for all integers N >= 0.
  573. 1 = 1 mod 3. 10 = 1 mod 3. 10^N = 10^(N-1) * 10 = 10^(N-1) mod 3.
  574. QED by induction. 
  575. Now let D[0] be the units digit of N, D[1] the tens digit, etc.
  576. Now N = Summation From k=0 to k=inf of D[k]*10^k.
  577. Therefore N mod 3 = Summation from k=0 to k=inf of D[k] mod 3. QED
  578.